if exists (select 1 from sysobjects where name = 'upd_planstatus' and type = 'P')
begin
   drop procedure upd_planstatus
   print 'Procedure: upd_planstatus deleted ...'
end
go
create procedure upd_planstatus(
  @statusin          int           = 1,  -- 1: Aktiv   2: Inaktiv
  @planidin          int           = 1
)
as
begin
  set nocount on

   if @statusin = 0 select @statusin = 1 -- per default aktiv

   begin
      update ArbeitsPlan set Status = @statusin
       where ArbeitsPlan.PlanID = @planidin
   end
end
go
print 'Procedure: upd_planstatus done ...'
go
grant exec on upd_planstatus to prsadmins with grant option
go
grant exec on upd_planstatus to prsusers
go

